package md.lanjing.com.module_deal_center.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.Md5Utils;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;
;
import md.lanjing.com.module_deal_center.R;
import md.lanjing.com.module_deal_center.api.DealApiService;
import com.lxh.baselibray.base.BaseResponce;
import md.lanjing.com.module_deal_center.bean.CheckOrderDetailResponce;
import com.lxh.baselibray.constant.Constant;
import md.lanjing.com.module_deal_center.bean.CheckOrderDetailConfirmRequest;
import retrofit2.Call;
import retrofit2.Response;

public class CheckOrderDetailContact {
    public static class  CheckOrderDetailPresent extends BasePresent<ICheckOrderDetailView> {
        public void checkBillDetail(final Context context, String transferId){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            service.queryCheckOrderDetail(transferId).enqueue(new NetCallBack<CheckOrderDetailResponce>() {
                @Override
                public void onSuccess(Call<CheckOrderDetailResponce> call, Response<CheckOrderDetailResponce> response) {
                    if (getView()!=null){
                        getView().getCheckOrderDetailData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,context.getString(R.string.request_failed));
                }
            });
        }
        public void confirmCheckOrder(final Context context, String billId, String transferId, String dealPwd){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            CheckOrderDetailConfirmRequest request=new CheckOrderDetailConfirmRequest(billId,transferId,userId, Md5Utils.stringToMD5(dealPwd));
            service.checkOrderConfirm(request).enqueue(new NetCallBack<BaseResponce>() {
                @Override
                public void onSuccess(Call<BaseResponce> call, Response<BaseResponce> response) {
                    if (getView()!=null){
                        getView().getConfirmOrderData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,context.getString(R.string.request_failed));
                }
            });
        }
    }
    public interface ICheckOrderDetailView extends IBaseView {
        void getCheckOrderDetailData(Response<CheckOrderDetailResponce> response);
        void getConfirmOrderData(Response<BaseResponce> response);
    }
}
